package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	TdCategoryEventNew           = "td.TdCategoryNew"
	TdCategoryEventBeforeCreate  = "td.TdCategoryBeforeCreate"
	TdCategoryEventBeforeUpdate  = "td.TdCategoryBeforeUpdate"
	TdCategoryEventBeforeSave    = "td.TdCategoryBeforeCreate td.TdCategoryBeforeUpdate"
	TdCategoryEventAfterCreate   = "td.TdCategoryAfterCreate"
	TdCategoryEventAfterUpdate   = "td.TdCategoryAfterUpdate"
	TdCategoryEventAfterSave     = "td.TdCategoryAfterCreate td.TdCategoryAfterUpdate"
	TdCategoryEventDelete        = "td.TdCategoryDelete"
	TdCategoryAccessControlEvent = "td.TdCategoryAccessControl"
)

func GetTdCategoryConfig() *mgo.DocConfig {
	return TdCategory_Config
}

var TdCategory_Config *mgo.DocConfig

func init() {
	TdCategory_Config = NewTdCategoryConfig()
}
func NewTdCategoryConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "td.TdCategory",
		Fields: []string{
			"name", "sort", "l", "r", "level", "link", "parent", "children", "color", "background", "group", "step", "warn",
		},
		RelationFields: []string{
			"parent", "children",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"parent": {
				Config:     GetTdCategoryConfig,
				DocName:    "TdCategory",
				JoinType:   "O",
				KeyInside:  "parentId",
				KeyOutSide: "id",
			},
			"children": {
				Config:     GetTdCategoryConfig,
				DocName:    "TdCategory",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "parentId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
